home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Precision Software Appli…tions Silver Collection 4
/
Precision Software Applications Silver Collection Volume 4 (1993).iso
/
stats
/
chadyn.exe
/
YCOMU.C
< prev
next >
Wrap
C/C++ Source or Header
|
1988-11-28
|
9KB
|
342 lines
/******************************** YCOMU.C **********************************/
/******************* UNSTABLE MANIFOLD COMMANDS AND MENU *********************/
/********************* (C) 1986,7,8 by JAMES A. YORKE ************************/
#include "yinclud.h"
#define STEST(x) (strcmp(CodeName,x) == 0)
#define TEST3(x,y,z) if( STEST(x) || STEST(y) || STEST(z) )
#define TEST4(w,x,y,z) if( STEST(w) || STEST(x) || STEST(y) || STEST(z) )
/* displacement for UL and UR commands */
#define TINY 0.00000001
int caseUs(CodeName) /* unstable manifolds */
char *CodeName;
{
double miss,
newton();
int invert(), acceptStable(), i, invertFlag = NO;
char *pCode = CodeName;
TEST("ab") { /* this command is not essential; it is not
called by anything; this is very similar to
InterrupyL in YINTRPT.C which is called by
interrupt 'L' */
abcd();
return(1);
}
TEST("lineinfo") {
PRINT
" LI number of iterates of line( >=0 ); now %d \n\n"
,UIterates);
PRINT
" LC Sets the line horizontally,length .002, centered at y[]\n");
PRINT
"Alternatives:\n SX To set the x coordinate of the starting point; now %lf\n"
,line_x1);
PRINT
" SY To set the y coordinate of the starting point; now %lf\n"
,line_y1);
PRINT
" FX To set the x coordinate of the end point; now %lf\n"
,line_x2);
PRINT
" FY To set the y coordinate of the end point; now %lf \n"
,line_y2);
PRINT
" RDL to draw the line and its iterates on top of old picture\n");
PRINT
" DL to draw the line and its iterates after clearing screen\n");
PRINT
" RDL to draw the line and its iterates on top of old picture\n");
PRINT
" LD: number of Dots on Line; now %d \n"
,linedots);
PRINT
" TAV: draw image of line one period in length, constant phase space=y1[] \n"
);
PRINT
" RTAV: does same as TAV except it restores the old picture first \n"
);
return(1);
}
TEST("ld") {
linedots = (int) Entervalue((double) linedots, CHECKSET);
return(1);
}
TEST("ulen") {
PRINT
"To set the length of the unstable manifold to be computed, \n");
PRINT
"(= number of diagonals long) \n");
ULength = Entervalue(ULength, CHECKSET);
return(1);
}
TEST("upix") {
PRINT
"To speed the plotting you can plot every couple pixels of the unstable \n");
PRINT
"manifold and you can interpolate in between. Enter number(default=4) \n");
numPixels = (int) Entervalue((double) numPixels, CHECKSET);
return(1);
}
TEST4 ("sl1", "rsl1", "ul1", "rul1") {
if(level == 2)
scr_clr();
if(CodeName[0] == 'r') {
pCode++;/* pointer to first non 'r' character of
CodeName */
boot = 1;
}
if(*pCode == 's') {/* see if it is a stable manifold */
if(acceptStable() == NO)
return(1);
invertFlag = YES;
}
else
invertFlag = NO;
miss = newton(period, 1);
/* 1 means quasi-newton as opposed to newton;
MISS is the amount that the trajectory
misses being closed by */
for(i = 0; i < 8 && miss > TINY / 100.; i++)
miss = newton(period, 1);
store(y, y + eqnsL, dim);
y[X_coord] = y[X_coord] - TINY * (X_upper - X_lower);
LineForU(period);
LineIterator(40, period);
if(invertFlag == YES)
/* see if it is a stable manifold; if so, we
must re-invert */
invert();
return(1);
}
TEST4 ("sl", "rsl", "ul", "rul") {
/* left stable of unstable manifold */
if(level == 2)
scr_clr();
if(CodeName[0] == 'r') {
pCode++;/* pointer to first non 'r' character of
CodeName */
boot = 1;
}
if(*pCode == 's') {/* see if it is a stable manifold */
if(acceptStable() == NO)
return(1);
invertFlag = YES;
}
else
invertFlag = NO;
miss = newton(period, 1);
/* 1 means quasi-newton as opposed to newton;
MISS is the amount that the trajectory
misses being closed by */
for(i = 0; i < 8 && miss > TINY / 100.; i++)
miss = newton(period, 1);
store(y, y + eqnsL, dim);
y[X_coord] = y[X_coord] - TINY * (X_upper - X_lower);
LineForU(2 * period);
LineIterator(40, 2 * period);
if(invertFlag == YES)
/* see if it is a stable manifold; if so, we
must re-invert */
invert();
return(1);
}
TEST4 ("sr", "rsr", "ur", "rur") {
if(level == 2)
scr_clr();
if(CodeName[0] == 'r') {
pCode++;/* pointer to first non 'r' character of
CodeName */
boot = 1;
}
if(*pCode == 's') {/* see if it is a stable manifold */
if(acceptStable() == NO)
return(1);
invertFlag = YES;
}
else
invertFlag = NO;
miss = newton(period, 1);
/* 1 means quasi-newton as opposed to newton;
MISS is the amount that the trajectory
misses being closed by */
for(i = 0; i < 8 && miss > TINY / 100.; i++) {
miss = newton(period, 1);
}
store(y, y + eqnsL, dim);
y[X_coord] = y[X_coord] + TINY * (X_upper - X_lower);
LineForU(2 * period);
LineIterator(40, 2 * period);
if(invertFlag == YES)
/* see if it is a stable manifold; if so, we
must re-invert */
invert();
return(1);
}
TEST4 ("sr1", "rsr1", "ur1", "rur1") {
if(level == 2)
scr_clr();
if(CodeName[0] == 'r') {
pCode++;/* pointer to first non 'r' character of
CodeName */
boot = 1;
}
if(*pCode == 's') {/* see if it is a stable manifold */
if(acceptStable() == NO)
return(1);
invertFlag = YES;
}
else
invertFlag = NO;
miss = newton(period, 1);
/* 1 means quasi-newton as opposed to newton;
MISS is the amount that the trajectory
misses being closed by */
for(i = 0; i < 8 && miss > TINY / 100.; i++)
miss = newton(period, 1);
store(y, y + eqnsL, dim);
y[X_coord] = y[X_coord] + TINY * (X_upper - X_lower);
LineForU(period);
LineIterator(40, period);
if(invertFlag == YES)
/* see if it is a stable manifold; if so, we
must re-invert */
invert();
return(1);
}
TEST("sx") {
line_x1 = Entervalue(line_x1, CHECKSET);
return(1);
}
TEST("sy") {
line_y1 = Entervalue(line_y1, CHECKSET);
return(1);
}
TEST("fx") {
line_x2 = Entervalue(line_x2, CHECKSET);
return(1);
}
TEST("fy") {
line_y2 = Entervalue(line_y2, CHECKSET);
return(1);
}
TEST("li") { /* line iterates */
UIterates = (int) Entervalue((double) UIterates, CHECKSET);
return(1);
}
return(0);
}
abcd() {
double savea[EQUATIONS],
saveb[EQUATIONS];
int oldCycle;
oldCycle = cycle;
cycle = 0;
store(savea, ya, dim); /* ya and yb are used in line drawing */
store(saveb, yb, dim);
if(ya[X_coord] == -9999.|| yb[X_coord] == -9999.)
PRINT "ya or yb is not set \n");
else {
if(printer > 1)
PRINT "Number of images now = %d\n", images);
if(ya[0] != -9999.&& yb[0] != -9999.) {
makeLine(savea, saveb, ya, yb, images);
}
if(ya[0] != -9999.&& yb[0] != -9999.
&& yc[0] != -9999.) {
makeLine(savea, saveb, yb, yc, images);
}
if(ya[0] != -9999.&& yb[0] != -9999.
&& yc[0] != -9999.&& yd[0] != -9999.) {
makeLine(savea, saveb, yc, yd, images);
store(ya, savea, dim);
makeLine(savea, saveb, yd, ya, images);
}
}
cycle = oldCycle;
}
makeLine(savea, saveb, y1val, y2, its)
double *savea,
*saveb,
*y1val,
*y2;
int its;
{
store(ya, y1val, dim);
store(yb, y2, dim);
LineForB(ya, yb); /* does not do much */
connect2 (ya[X_coord], ya[Y_coord], yb[X_coord], yb[Y_coord]);
if(its > 0)
LineIterator(its, 1);
store(ya, savea, dim);
store(yb, saveb, dim);
}
ManifoldMenu() {
if(level == SETPARAM)
scr_clr(); /* in desmets pcio.a */
scr_rowcol(1, 0);
PRINT
" MENU for STABLE and UNSTABLE MANIFOLDS \n\n");
PRINT
" AB: connect ya to yb.,draw IMAGES. \n");
PRINT
" UPIX: changes the number of pixels plotted per computation; now = %d \n\n"
,numPixels);
PRINT
" UL: computes left side of unstable manifold at y1[]\n");
PRINT
" UR: computes right side of unstable manifold at y1[]\n");
PRINT
" RUL and RUR are like UL & UR, but Restore previous picture first.\n\n");
PRINT
" SL,SR,RSL,RSR: the corresponding STABLE MANIFOLD commands require inverse\n"
);
PRINT
" to be available; they do work for Henon and Differential Equations\n");
PRINT
"\nRelated commands in other menus:\n");
PRINT
" Nx or Qx: You must set y1 at a periodic point before invoking stable and\n");
PRINT
" unstable manifold commands; see N menu\n\n"
);
PRINT
" NP: sets the period of the orbit(currently %d)\n",
period);
PRINT
" SD should be set somewhere between 0 and 1 to speed returns to screen\n");
erase_line();
PRINT
" Currently SD is %lf; see P menu \n\n"
,diameters[ScrnSec]);
}
int acceptStable() { /* returns whatever invert() returns */
if(invert() == NO) {
PRINT
"Stable Manifold processes require the inverse to be available;\n");
PRINT
"Stable Manifold processes work for Henon and Differential equations\n");
return(NO);
}
return(YES);
}